counter.CounterJvn2 Class Reference

List of all members.

Static Public Member Functions

static void main (String[] args)


Detailed Description

This class defines a stress test for the Javanaise system. Different instances will try to count, without skipping any number.

Definition at line 17 of file CounterJvn2.java.


Member Function Documentation

static void counter.CounterJvn2.main ( String[]  args  )  [static]

Main class. Will create a shared integer object and start counting.

Parameters:
args 

Definition at line 23 of file CounterJvn2.java.

References jvn.JvnException.getMessage(), jvn.JvnServerImpl.jvnLookupObject(), jvn.JvnServerImpl.jvnRegisterObject(), and jvn.JvnObjectImpl.jvnUnLock().

00023                                                {
00024                 try {
00025                         // initialize JVN
00026                         JvnServerImpl js = JvnServerImpl.jvnGetServer();
00027                         
00028                         if (js == null) {
00029                                 System.out.println("Counter stress test problem : cannot create server!");
00030                         }
00031                         else {
00032                                 // look up the IRC object in the JVN server
00033                                 // if not found, create it, and register it in the JVN server
00034                                 
00035                                 JvnIntegerWrapper jo = (JvnIntegerWrapper)(js.jvnLookupObject("Counter",JvnIntegerWrapper.class));
00036                                 if (jo == null) {
00037                                         jo = new JvnIntegerWrapper();
00038                                         // after creation, I have a write lock on the object
00039                                         jo.jvnUnLock();
00040                                         js.jvnRegisterObject("Counter", jo);
00041                                 }
00042                                 while(true) {
00043                                         try {
00044                                                 int number = jo.read();
00045                                                 System.out.println("Current number is "+number+", next number shall be "+(++number));
00046                                                 jo.write(number);
00047                                         } catch (JvnException je) {
00048                                                 System.out.println("Counter stress test problem : " + je.getMessage());
00049                                         }
00050                                 }
00051                         }
00052                 } catch (JvnException je) {
00053                         System.out.println("Counter stress test problem : " + je.getMessage());
00054                 }
00055         }

Here is the call graph for this function:


The documentation for this class was generated from the following file:
Generated on Wed Jan 2 10:15:56 2008 for Javanaise by  doxygen 1.5.4